package apiday05homework;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        /*
        FileOutputStream fos = new FileOutputStream("test1.txt", true);
        String line = "hello你好";
        byte[] data = line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
        line = "你好hello";
        data = line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
        System.out.println("数据写出完毕");
        fos.close();

         */
        FileOutputStream fos = new FileOutputStream("test1.txt", true);
        String line = "你是一个一个一个";
        byte[] data= line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);

        line = "这是何物？";
        data =line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
        System.out.println("数据写出完毕");
        fos.close();
    }
}
